package programs.expression.implementedClasses;

import programs.expression.superClasses.BinaryBooleanExpression;
import programs.expression.superClasses.Expression;
import programs.expression.superClasses.ExpressionType;

public class OR extends BinaryBooleanExpression {

	public OR(Expression left, Expression right) {
		super(left, right);
	}

	@Override
	public Object getValue() {
		return ((Boolean) getSubExpressionAt(1).getValue()) || ((Boolean) getSubExpressionAt(2).getValue());
	}
	
	@Override
	public boolean isValidExpression() {
		return ( super.isValidExpression() 
				&& (getSubExpressionAt(1).getReturnType() == ExpressionType.BOOLEAN)
				&& (getSubExpressionAt(2).getReturnType() == ExpressionType.BOOLEAN) ); 
	}

}
